package com.eastfair.auth.service.impl;

//import com.baomidou.dynamic.datasource.annotation.DS;
import com.eastfair.auth.dto.OrganizationDTO;
import com.eastfair.auth.entity.Organization;
import com.eastfair.auth.entity.OrganizationRole;
import com.eastfair.auth.entity.ResourceOrganization;
import com.eastfair.auth.enumeration.OrganizationOrgTypeEnum;
import com.eastfair.auth.enumeration.OrganizationVestTypeEnum;
import com.eastfair.auth.enumeration.ResourceOrganizationResourceTypeEnum;
import com.eastfair.auth.service.*;
import com.eastfair.constant.BusinessConstant;
import com.eastfair.core.base.R;
import com.eastfair.core.context.ContextUtil;
import com.eastfair.core.exception.code.ExceptionCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static com.eastfair.core.base.R.SUCCESS_CODE;

/**
 * <p>
 * 场馆内部操作业务接口实现类
 *
 * </p>
 *
 * @author ligang
 * @date 2022-07-16
 */
@Slf4j
@Service
//@DS("#thread.tenant")
public class RbookingOrganizationServiceImpl implements RbookingOrganizationService {

    @Autowired
    XiamenOrganizationService xiamenOrganizationService;

    @Override
    public Organization query(OrganizationDTO organizationDTO) {
        OrganizationOrgTypeEnum organizationOrgTypeEnum = OrganizationOrgTypeEnum.BOOKING;
        Organization organization = xiamenOrganizationService.query(organizationDTO, organizationOrgTypeEnum);
        return organization;
    }

    @Override
    public R<Organization> create(OrganizationDTO organizationDTO) {
        //资源节点类型
        OrganizationOrgTypeEnum resourceOrgType = OrganizationOrgTypeEnum.BOOKING;
        //资源节点员工类型
        OrganizationOrgTypeEnum resourceOrgTypeStaff = OrganizationOrgTypeEnum.BOOKING_STAFF;
        return xiamenOrganizationService.create(organizationDTO, resourceOrgType, resourceOrgTypeStaff);
    }

    @Override
    public R<Organization> upd(OrganizationDTO organizationDTO) {
        return xiamenOrganizationService.upd(organizationDTO);
    }

    @Override
    public R del(OrganizationDTO organizationDTO) {
        OrganizationOrgTypeEnum organizationOrgTypeEnum = OrganizationOrgTypeEnum.BOOKING;
        return xiamenOrganizationService.del(organizationDTO, organizationOrgTypeEnum);
    }

    @Override
    public R addUser(OrganizationDTO organizationDTO, Integer isAdmin) {
        //资源节点类型
        OrganizationOrgTypeEnum resourceOrgType = OrganizationOrgTypeEnum.BOOKING;
        //员工节点类型
        OrganizationOrgTypeEnum resourceOrgStaffType = OrganizationOrgTypeEnum.BOOKING_STAFF;
        return xiamenOrganizationService.addUser(organizationDTO, isAdmin, resourceOrgType, resourceOrgStaffType);
    }

    @Override
    public R breakUser(OrganizationDTO organizationDTO) {
        //资源节点类型
        OrganizationOrgTypeEnum resourceOrgType = OrganizationOrgTypeEnum.BOOKING;
        return xiamenOrganizationService.breakUser(organizationDTO, resourceOrgType);
    }

}
